<?php
	set_include_path (PHPPATH);
	require_once 'MDB2.php';
    /**
     * 
     * The searchlist controller
     * @author Tri
     *
     */
    class searchList extends Application 
    {
        /**
         * 
         * Constructor
         */
        function __construct(&$tmpl)
        {            
            $this->tmpl = &$tmpl;        
        }

        /**
         * 
         * Default action
         */
        function productSearchByNameList()
        {
            $currentView = $_REQUEST['view'];
            $this->assign("currentView", $currentView);
            $backTitle = $_REQUEST['back'];
            $this->assign("backTitle", $backTitle);

            $txtSearch = $_REQUEST['keyword'];
            $this->assign("keyword", $txtSearch);
            $productModel = $this->getModel('ProductModel');
            $productSearch = $productModel->getAllProductSearchByName($txtSearch);
            
            $this->assign("imagesPath", $this->loadResources('images'));
            $this->assign("productPath", $this->loadResources('product'));
            $this->assign('products',$productSearch);
            $this->assign("products_count", count($productSearch));        
            
            $this->assign("page", "sear");
            $this->assign("pageId", 1);
            $this->assign("sf", "name");
            $this->assign("kw", $txtSearch);
            $this->assign("title", 'Name: '.$txtSearch);
            
            $this->loadPageTemplate('product_list_page');
        }
        
        function productSearchByBrandList()
        {
            $currentView = $_REQUEST['view'];
            $this->assign("currentView", $currentView);
            $backTitle = $_REQUEST['back'];
            $this->assign("backTitle", $backTitle);
            
            $txtSearch = $_REQUEST['keyword'];
            $this->assign("keyword", $txtSearch);
            $productModel = $this->getModel('ProductModel');
            $productSearch = $productModel->getAllProductSearchByBrand($txtSearch);
            
            $this->assign("imagesPath", $this->loadResources('images'));
            $this->assign("productPath", $this->loadResources('product'));
            $this->assign('products',$productSearch);
            $this->assign("products_count", count($productSearch));        
            
            $this->assign("page", "sear");
            $this->assign("pageId", 2);
            $this->assign("sf", "brand");
            $this->assign("kw", $txtSearch);
            $this->assign("title", 'Brand: '.$txtSearch);
            
            $this->loadPageTemplate('product_list_page');
        }
        
        function productSearchByStoreList()
        {
            $currentView = $_REQUEST['view'];
            $this->assign("currentView", $currentView);
            $backTitle = $_REQUEST['back'];
            $this->assign("backTitle", $backTitle);
            
            $txtSearch = $_REQUEST['keyword'];
            $this->assign("keyword", $txtSearch);
            $productModel = $this->getModel('ProductModel');
            $productSearch = $productModel->getAllProductSearchByStore($txtSearch);
            
            $this->assign("imagesPath", $this->loadResources('images'));
            $this->assign("productPath", $this->loadResources('product'));
            $this->assign('products',$productSearch);
            $this->assign("products_count", count($productSearch));        
            
            $this->assign("page", "sear");
            $this->assign("pageId", 3);
            $this->assign("sf", "store");
            $this->assign("kw", $txtSearch);
            $this->assign("title", 'Store: '.$txtSearch);
            
            $this->loadPageTemplate('product_list_page');
        }
    }
?>